home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / LEV_LEX.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  32KB  |  1,117 lines

  1. #define FLEX_COMPRESSED
  2. /* A lexical scanner generated by flex */
  3.  
  4. /* scanner skeleton version:
  5.  * $Header: flex.skel,v 2.0 89/06/20 15:49:46 vern Locked $
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. #define FLEX_SCANNER
  11.  
  12. /* amount of stuff to slurp up with each read */
  13. #ifndef YY_READ_BUF_SIZE
  14. #define YY_READ_BUF_SIZE 8192
  15. #endif
  16.  
  17. #ifndef YY_BUF_SIZE
  18. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of input buffer */
  19. #endif
  20.  
  21. /* returned upon end-of-file */
  22. #define YY_END_TOK 0
  23.  
  24. /* copy whatever the last rule matched to the standard output */
  25.  
  26. #define ECHO fputs( yytext, yyout )
  27.  
  28. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  29.  * is returned in "result".
  30.  */
  31. #ifdef atarist
  32. static __st_read(fd, buf, size)
  33. int fd; char *buf; int size;
  34. {
  35.     int r, num = 0;
  36.     char *from;
  37.  
  38.     if ((r = read(fd, buf, size)) < 0)
  39.         return r;
  40.     from = buf;
  41.     while (r-- > 0) {
  42.         if (*from == '\r')
  43.             from++;
  44.         else {
  45.             *buf++ = *from++;
  46.             num++;
  47.         }
  48.     }
  49.     return num;
  50. }
  51.  
  52. #define YY_INPUT(buf,result,max_size) \
  53.     if ( (result = __st_read( fileno(yyin), buf, max_size )) < 0 ) \
  54.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  55.  
  56. #else
  57.  
  58. #define YY_INPUT(buf,result,max_size) \
  59.     if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
  60.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  61. #endif
  62.  
  63. #define YY_NULL 0
  64. #define yyterminate() return ( YY_NULL )
  65.  
  66. /* report a fatal error */
  67. #define YY_FATAL_ERROR(msg) \
  68.     { \
  69.     fputs( msg, stderr ); \
  70.     putc( '\n', stderr ); \
  71.     exit( 1 ); \
  72.     }
  73.  
  74. /* default yywrap function - always treat EOF as an EOF */
  75. #define yywrap() 1
  76.  
  77. /* enter a start condition.  This macro really ought to take a parameter,
  78.  * but we do it the disgusting crufty way forced on us by the ()-less
  79.  * definition of BEGIN
  80.  */
  81. #define BEGIN yy_start = 1 + 2 *
  82.  
  83. /* action number for EOF rule of a given start state */
  84. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  85.  
  86. /* special action meaning "start processing a new file" */
  87. #define YY_NEW_FILE goto new_file
  88.  
  89. /* default declaration of generated scanner - a define so the user can
  90.  * easily add parameters
  91.  */
  92. #ifdef __STDC__
  93. #define YY_DECL int yylex( void )
  94. #else
  95. #define YY_DECL int yylex()
  96. #endif
  97.  
  98. /* code executed at the end of each rule */
  99. #define YY_BREAK break;
  100.  
  101. #define YY_END_OF_BUFFER_CHAR 0
  102.  
  103. /* done after the current pattern has been matched and before the
  104.  * corresponding action - sets up yytext
  105.  */
  106. #define YY_DO_BEFORE_ACTION \
  107.     yytext = yy_bp; \
  108.     yy_hold_char = *yy_cp; \
  109.     *yy_cp = '\0'; \
  110.     yy_c_buf_p = yy_cp;
  111.  
  112. /* returns the length of the matched text */
  113. #define yyleng (int)(yy_cp - yy_bp)
  114.  
  115. #define EOB_ACT_RESTART_SCAN 0
  116. #define EOB_ACT_END_OF_FILE 1
  117. #define EOB_ACT_LAST_MATCH 2
  118.  
  119. /* return all but the first 'n' matched characters back to the input stream */
  120. #define yyless(n) \
  121.     { \
  122.     *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
  123.     yy_c_buf_p = yy_cp = yy_bp + n; \
  124.     YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  125.     }
  126.  
  127. #define unput(c) yyunput( c, yy_bp )
  128.  
  129. #define YY_USER_ACTION
  130.  
  131. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  132. char *yytext;
  133.  
  134. #ifndef __STDC__
  135. #define const
  136. #endif
  137.  
  138. # line 1 "lev_comp.l"
  139. #define INITIAL 0
  140. # line 2 "lev_comp.l"
  141. /*    SCCS Id: @(#)lev_lex.c    3.0    90/01/04
  142. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  143. /* NetHack may be freely redistributed.  See license for details. */
  144.  
  145. #define LEV_LEX_C
  146.  
  147. /* block some unused #defines to avoid overloading some cpp's */
  148. #define MONDATA_H    /* comment this line for pre-compiled headers */
  149. #define MONFLAG_H    /* comment this line for pre-compiled headers */
  150.  
  151. #include "hack.h"
  152. #include "lev_comp.h"
  153. #include "sp_lev.h"
  154.  
  155. /* Most of these don't exist in flex, yywrap is macro and
  156.  * yyunput is properly declared in flex.skel.
  157.  */
  158. #ifndef FLEX_SCANNER
  159. int FDECL (yyback, (int *, int));
  160. int NDECL (yylook);
  161. int NDECL (yyinput);
  162. int NDECL (yywrap);
  163. int NDECL (yylex);
  164. int FDECL (yyunput, (int));
  165. int FDECL (yyoutput, (int));
  166. #endif
  167.  
  168. #ifdef MSDOS
  169. #undef exit
  170. extern void FDECL(exit, (int));
  171. #endif
  172.  
  173. /* this doesn't always get put in lev_comp.h
  174.  * (esp. when using older versions of bison)
  175.  */
  176.  
  177. extern YYSTYPE yylval;
  178.  
  179. #ifdef MACOS
  180. #undef putchar
  181. #undef putc
  182. #undef printf
  183. #undef Printf
  184. #define Printf printf
  185. # ifdef LSC
  186. #define    putc(c,stream)    (fputc(c,stream))
  187. #define    putchar(c)    (fputc(c,stdout))
  188. # endif
  189. #endif
  190. int line_number = 1;
  191.  
  192. /* This is *** UGLY *** but I can't think a better way to do it
  193.  * I really need a huge buffer to scan maps...
  194.  */
  195.  
  196. #undef YYLMAX
  197. #define YYLMAX    2048
  198.  
  199. #define MAPC 1
  200. # line 62 "lev_comp.l"
  201. #define YY_END_OF_BUFFER 57
  202. typedef int yy_state_type;
  203. static const short int yy_accept[274] =
  204.     {   0,
  205.         0,    0,    0,    0,   57,   55,   53,   52,   55,   55,
  206.        50,   55,   55,   55,   55,   55,   55,   55,   55,   55,
  207.        55,   55,   55,   55,   55,   55,   55,   55,   55,   55,
  208.        55,   55,   55,   55,   55,   55,   55,    1,   53,   55,
  209.        55,   55,   53,    0,   51,    0,   50,    0,    0,    0,
  210.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  211.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  212.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  213.         0,    0,    0,    0,    0,   48,    0,    0,    3,    0,
  214.         1,   53,    0,    0,    1,    0,   54,    0,    0,    0,
  215.  
  216.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  217.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  218.        43,    0,   41,    0,    0,    0,    0,    0,    0,    0,
  219.         0,    0,    0,    0,    0,   39,    0,    0,    0,    0,
  220.         0,   11,    0,    0,    0,    0,    4,    0,    0,    0,
  221.         0,    0,   21,   10,    0,    0,    0,    0,    0,    0,
  222.         0,   49,   28,   36,    0,    0,    0,    0,    0,    0,
  223.        22,    0,    0,    0,    0,    0,    0,   30,    7,    0,
  224.        18,    0,    0,    0,    5,    0,    0,    0,    0,    0,
  225.         0,   35,   47,    0,    0,    0,   45,    0,    0,    0,
  226.  
  227.         0,    0,   27,    0,   34,    0,   37,    0,   29,   42,
  228.         0,    0,    0,   19,    0,    0,    0,    8,    0,   14,
  229.        40,   26,   38,   23,   24,    0,    0,   25,   32,   31,
  230.        46,    0,    0,    0,    0,    9,    0,    0,   33,   44,
  231.         2,    0,    6,   13,    0,    0,    0,    0,    0,    0,
  232.         0,    0,    0,   12,    0,    0,    0,    0,    0,    0,
  233.         0,    0,   20,    0,    0,    0,    0,    0,   17,    0,
  234.        15,   16,    0
  235.     } ;
  236.  
  237. static const char yy_ec[128] =
  238.     {   0,
  239.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  240.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  241.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  242.         1,    4,    1,    5,    6,    1,    1,    1,    7,    1,
  243.         1,    1,    8,    1,    8,    8,    1,    9,    9,    9,
  244.         9,    9,    9,    9,    9,    9,    9,    1,    1,    1,
  245.         1,    1,    1,    1,   10,   11,   12,   13,   14,    1,
  246.        15,    1,   16,   17,   18,   19,   20,   21,   22,   23,
  247.         1,   24,   25,   26,    1,   27,   28,    1,   29,   30,
  248.         1,    8,    1,    1,   31,    1,   32,   33,   34,   35,
  249.  
  250.        36,   37,   38,   39,   40,   41,   42,   43,   44,   45,
  251.        46,   47,    1,   48,   49,   50,   51,    1,   52,    1,
  252.         1,    1,    8,    8,    8,    1,    1
  253.     } ;
  254.  
  255. static const char yy_meta[53] =
  256.     {   0,
  257.         1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
  258.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  259.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  260.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  261.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  262.         1,    1
  263.     } ;
  264.  
  265. static const short int yy_base[277] =
  266.     {   0,
  267.         0,   47,   51,   74,  343,  344,   54,  344,  337,    0,
  268.       332,  321,   38,  325,   54,   51,  316,  326,   61,  312,
  269.       292,   24,   48,  288,  301,   49,  286,   50,   46,  288,
  270.        34,   51,  284,   53,  293,  325,   91,  344,  100,  106,
  271.       306,  124,  103,  321,  344,  318,  315,  297,  300,  311,
  272.       298,  306,  291,  287,  295,  294,  297,  292,  297,  289,
  273.       300,   71,  259,  262,  262,  274,  259,  252,  254,  250,
  274.       264,  250,  265,  253,  246,   81,  255,  259,  262,  248,
  275.       254,  243,  239,  242,  245,  344,  238,  283,  344,   92,
  276.       344,  132,  140,  272,  344,  148,  344,  274,  259,  254,
  277.  
  278.       261,  267,  265,  264,  252,  245,  261,  261,  257,  252,
  279.       248,  232,  237,  218,  225,  216,  219,  215,  218,  212,
  280.       344,  211,  344,  218,  210,  208,  211,  206,  219,  209,
  281.       219,  217,  212,  210,  199,  344,  208,  197,  243,  225,
  282.       220,  344,  232,  228,  227,  221,  211,  212,  224,  224,
  283.       213,  212,  344,  344,  188,  184,  185,  194,  193,  179,
  284.       191,  344,  344,  344,  190,  175,  176,  177,  183,  187,
  285.       344,  184,  173,  168,  172,  177,  165,  344,  344,  204,
  286.       344,  189,  186,  187,  344,  200,  195,  192,  181,  186,
  287.       184,  344,  344,  160,  158,  154,  344,  166,  165,  163,
  288.  
  289.       166,  149,  344,  146,  344,  151,  344,  158,  344,  344,
  290.       170,  176,  167,  344,  171,  165,  173,  344,  156,  344,
  291.       344,  344,  344,  344,  344,  138,  142,  344,  344,  344,
  292.       344,  181,  170,  153,  163,  344,  165,   97,  344,  344,
  293.       344,  164,  344,  344,  168,  150,  160,  151,  155,  157,
  294.       146,  147,  153,  344,  143,  136,  146,  147,  141,  127,
  295.       135,  131,  344,  127,  113,  112,  109,  101,  344,   98,
  296.       344,  344,  344,  173,   62,  175
  297.     } ;
  298.  
  299. static const short int yy_def[277] =
  300.     {   0,
  301.       273,    1,    1,    1,  273,  273,  273,  273,  274,  275,
  302.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  303.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  304.       273,  273,  273,  273,  273,  276,  273,  273,  273,  273,
  305.       273,  276,  273,  274,  273,  273,  273,  273,  273,  273,
  306.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  307.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  308.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  309.       273,  273,  273,  273,  273,  273,  273,  276,  273,  273,
  310.       273,  273,  273,  273,  273,  276,  273,  273,  273,  273,
  311.  
  312.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  313.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  314.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  315.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  316.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  317.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  318.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  319.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  320.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  321.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  322.  
  323.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  324.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  325.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  326.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  327.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  328.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  329.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  330.       273,  273,    0,  273,  273,  273
  331.     } ;
  332.  
  333. static const short int yy_nxt[397] =
  334.     {   0,
  335.         6,    7,    8,    7,    9,    6,   10,    6,   11,   12,
  336.         6,    6,   13,    6,   14,    6,    6,    6,   15,   16,
  337.        17,   18,    6,   19,    6,   20,    6,    6,    6,    6,
  338.         6,   21,   22,   23,   24,   25,    6,    6,    6,    6,
  339.         6,    6,   26,   27,   28,   29,   30,   31,   32,   33,
  340.        34,   35,   36,   38,   39,   43,   40,   43,   40,   49,
  341.        54,   50,   46,   52,   41,   80,   37,   53,   40,   63,
  342.        58,   64,   55,   81,   59,   40,   38,   39,   77,   42,
  343.        70,   40,   60,   65,   71,   75,   66,   41,   72,   82,
  344.        67,   40,   78,   37,   73,   76,   83,   85,   40,   86,
  345.  
  346.        90,   43,   91,   92,   43,   93,   43,   93,   91,   93,
  347.       112,   93,   55,   93,  139,  127,  246,   93,  247,  248,
  348.       113,  104,  272,   93,   93,  271,   95,   96,  128,   96,
  349.        93,   96,  270,   43,   91,   92,  269,   93,  268,   93,
  350.       267,   96,   91,   93,  266,   93,  265,   93,   96,   93,
  351.        95,   96,  264,   96,  263,   96,   93,   93,  262,  261,
  352.       260,  259,  258,  257,   93,   96,  256,  255,  254,  253,
  353.       252,  251,   96,   44,   44,   88,   88,  250,  249,  245,
  354.       244,  243,  242,  241,  240,  239,  238,  237,  236,  235,
  355.       234,  233,  232,  231,  230,  229,  228,  227,  226,  225,
  356.  
  357.       224,  223,  222,  221,  220,  219,  218,  217,  216,  215,
  358.       214,  213,  212,  211,  210,  209,  208,  207,  206,  205,
  359.       204,  203,  202,  201,  200,  199,  198,  197,  196,  195,
  360.       194,  193,  192,  191,  190,  189,  188,  187,  186,  185,
  361.       184,  183,  182,  181,  180,  179,  178,  177,  176,  175,
  362.       174,  173,  172,  171,  170,  169,  168,  167,  166,  165,
  363.       164,  163,  162,  161,  160,  159,  158,  157,  156,  155,
  364.       154,  153,  152,  151,  150,  149,  148,  147,  146,  145,
  365.       144,  143,  142,  141,  140,   89,  138,  137,  136,  135,
  366.       134,  133,  132,  131,  130,  129,  126,  125,  124,  123,
  367.  
  368.       122,  121,  120,  119,  118,  117,  116,  115,  114,  111,
  369.       110,  109,  108,  107,  106,  105,  104,  103,  102,  101,
  370.       100,   99,   98,   47,   97,   45,   94,   89,   87,   84,
  371.        79,   74,   69,   68,   62,   61,   57,   56,   51,   48,
  372.        47,   45,  273,    5,  273,  273,  273,  273,  273,  273,
  373.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  374.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  375.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  376.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  377.       273,  273,  273,  273,  273,  273
  378.  
  379.     } ;
  380.  
  381. static const short int yy_chk[397] =
  382.     {   0,
  383.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  384.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  385.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  386.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  387.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  388.         1,    1,    2,    3,    3,    7,    3,    7,    3,   13,
  389.        16,   13,  275,   15,    3,   31,    2,   15,    3,   22,
  390.        19,   22,   16,   31,   19,    3,    4,    4,   29,    4,
  391.        26,    4,   19,   23,   26,   28,   23,    4,   26,   32,
  392.        23,    4,   29,    4,   26,   28,   32,   34,    4,   34,
  393.  
  394.        37,   39,   39,   39,   43,   39,   43,   39,   40,   40,
  395.        62,   40,   37,   40,   90,   76,  238,   39,  238,  238,
  396.        62,   90,  270,   40,   39,  268,   42,   42,   76,   42,
  397.        40,   42,  267,   92,   92,   92,  266,   92,  265,   92,
  398.       264,   42,   93,   93,  262,   93,  261,   93,   42,   92,
  399.        96,   96,  260,   96,  259,   96,   92,   93,  258,  257,
  400.       256,  255,  253,  252,   93,   96,  251,  250,  249,  248,
  401.       247,  246,   96,  274,  274,  276,  276,  245,  242,  237,
  402.       235,  234,  233,  232,  227,  226,  219,  217,  216,  215,
  403.       213,  212,  211,  208,  206,  204,  202,  201,  200,  199,
  404.  
  405.       198,  196,  195,  194,  191,  190,  189,  188,  187,  186,
  406.       184,  183,  182,  180,  177,  176,  175,  174,  173,  172,
  407.       170,  169,  168,  167,  166,  165,  161,  160,  159,  158,
  408.       157,  156,  155,  152,  151,  150,  149,  148,  147,  146,
  409.       145,  144,  143,  141,  140,  139,  138,  137,  135,  134,
  410.       133,  132,  131,  130,  129,  128,  127,  126,  125,  124,
  411.       122,  120,  119,  118,  117,  116,  115,  114,  113,  112,
  412.       111,  110,  109,  108,  107,  106,  105,  104,  103,  102,
  413.       101,  100,   99,   98,   94,   88,   87,   85,   84,   83,
  414.        82,   81,   80,   79,   78,   77,   75,   74,   73,   72,
  415.  
  416.        71,   70,   69,   68,   67,   66,   65,   64,   63,   61,
  417.        60,   59,   58,   57,   56,   55,   54,   53,   52,   51,
  418.        50,   49,   48,   47,   46,   44,   41,   36,   35,   33,
  419.        30,   27,   25,   24,   21,   20,   18,   17,   14,   12,
  420.        11,    9,    5,  273,  273,  273,  273,  273,  273,  273,
  421.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  422.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  423.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  424.       273,  273,  273,  273,  273,  273,  273,  273,  273,  273,
  425.       273,  273,  273,  273,  273,  273
  426.  
  427.     } ;
  428.  
  429. /* the intent behind this definition is that it'll catch
  430.  * any uses of REJECT which flex missed
  431.  */
  432. #define REJECT reject_used_but_not_detected
  433. static char *yy_more_pos = (char *) 0;
  434. #define yymore() (yy_more_pos = yy_bp)
  435.  
  436. /* these variables are all declared out here so that section 3 code can
  437.  * manipulate them
  438.  */
  439. static char *yy_c_buf_p;    /* points to current character in buffer */
  440. static int yy_init = 1;        /* whether we need to initialize */
  441. static int yy_start = 0;    /* start state number */
  442.  
  443. /* true when we've seen an EOF for the current input file */
  444. static int yy_eof_has_been_seen;
  445.  
  446. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  447.  
  448. /* yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need
  449.  * to put in 2 end-of-buffer characters (this is explained where it is
  450.  * done) at the end of yy_ch_buf
  451.  */
  452. static char yy_ch_buf[YY_BUF_SIZE + 2];
  453.  
  454. /* yy_hold_char holds the character lost when yytext is formed */
  455. static char yy_hold_char;
  456.  
  457. static yy_state_type yy_last_accepting_state;
  458. static char *yy_last_accepting_cpos;
  459.  
  460. #ifdef __STDC__
  461. static yy_state_type yy_get_previous_state( void );
  462. static int yy_get_next_buffer( void );
  463. static void yyunput( int c, char *buf_ptr );
  464. static int input( void );
  465. static void yyrestart( FILE *input_file );
  466. #else
  467. static yy_state_type yy_get_previous_state();
  468. static int yy_get_next_buffer();
  469. static void yyunput();
  470. static int input();
  471. static void yyrestart();
  472. #endif
  473.  
  474. YY_DECL
  475.     {
  476.     register yy_state_type yy_current_state;
  477.     register char *yy_cp, *yy_bp;
  478.     register int yy_act;
  479.  
  480.  
  481.  
  482.     if ( yy_init )
  483.     {
  484.     if ( ! yy_start )
  485.         yy_start = 1;    /* first start state */
  486.  
  487.     if ( ! yyin )
  488.         yyin = stdin;
  489.  
  490.     if ( ! yyout )
  491.         yyout = stdout;
  492.  
  493. new_file:
  494.     /* this is where we enter upon encountering an end-of-file and
  495.      * yywrap() indicating that we should continue processing
  496.      */
  497.  
  498.     /* we put in the '\n' and start reading from [1] so that an
  499.      * initial match-at-newline will be true.
  500.      */
  501.  
  502.     yy_ch_buf[0] = '\n';
  503.     yy_n_chars = 1;
  504.  
  505.     /* we always need two end-of-buffer characters.  The first causes
  506.      * a transition to the end-of-buffer state.  The second causes
  507.      * a jam in that state.
  508.      */
  509.     yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  510.     yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  511.  
  512.     yy_eof_has_been_seen = 0;
  513.  
  514.     yytext = yy_c_buf_p = &yy_ch_buf[1];
  515.     yy_hold_char = *yy_c_buf_p;
  516.     yy_init = 0;
  517.     }
  518.  
  519.     while ( 1 )        /* loops until end-of-file is reached */
  520.     {
  521.     yy_cp = yy_c_buf_p;
  522.  
  523.     /* support of yytext */
  524.     *yy_cp = yy_hold_char;
  525.  
  526.     /* yy_bp points to the position in yy_ch_buf of the start of the
  527.      * current run.
  528.      */
  529.     if ( yy_more_pos )
  530.         {
  531.         yy_bp = yy_more_pos;
  532.         yy_more_pos = (char *) 0;
  533.         }
  534.     else
  535.         yy_bp = yy_cp;
  536.  
  537.     yy_current_state = yy_start;
  538.     if ( yy_bp[-1] == '\n' )
  539.         ++yy_current_state;
  540.     do
  541.         {
  542.         register char yy_c = yy_ec[*yy_cp];
  543.         if ( yy_accept[yy_current_state] )
  544.         {
  545.         yy_last_accepting_state = yy_current_state;
  546.         yy_last_accepting_cpos = yy_cp;
  547.         }
  548.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  549.         {
  550.         yy_current_state = yy_def[yy_current_state];
  551.         if ( yy_current_state >= 274 )
  552.             yy_c = yy_meta[yy_c];
  553.         }
  554.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  555.         ++yy_cp;
  556.         }
  557.     while ( yy_current_state != 273 );
  558.     yy_cp = yy_last_accepting_cpos;
  559.     yy_current_state = yy_last_accepting_state;
  560.  
  561.     /* bogus while loop to let YY_BACK_TRACK, EOB_ACT_LAST_MATCH,
  562.      * and EOF actions branch here without introducing an optimizer-
  563.      * daunting goto
  564.      */
  565.     while ( 1 )
  566.         {
  567.         yy_act = yy_accept[yy_current_state];
  568.  
  569.         YY_DO_BEFORE_ACTION;
  570.         YY_USER_ACTION;
  571.  
  572. #ifdef FLEX_DEBUG
  573.         fprintf( stderr, "--accepting rule #%d (\"%s\")\n",
  574.              yy_act, yytext );
  575. #endif
  576.  
  577. do_action:    /* this label is used only to access EOF actions */
  578.         switch ( yy_act )
  579.         {
  580.         case 0: /* must backtrack */
  581.         /* undo the effects of YY_DO_BEFORE_ACTION */
  582.         *yy_cp = yy_hold_char;
  583.         yy_cp = yy_last_accepting_cpos;
  584.         yy_current_state = yy_last_accepting_state;
  585.         continue; /* go to "YY_DO_BEFORE_ACTION" */
  586.  
  587. case 1:
  588. # line 63 "lev_comp.l"
  589. { line_number++; yymore(); }    
  590.     YY_BREAK
  591. case 2:
  592. # line 64 "lev_comp.l"
  593. { BEGIN 0;
  594.           line_number++;
  595.           yytext[yyleng-7] = 0; /* Discard \nENDMAP */
  596.           yylval.map = (char *) alloc(strlen(yytext)+1);
  597.           strcpy(yylval.map, yytext);
  598.           return MAP_ID;
  599.         }
  600.     YY_BREAK
  601. case 3:
  602. # line 71 "lev_comp.l"
  603. { line_number++; }
  604.     YY_BREAK
  605. case 4:
  606. # line 72 "lev_comp.l"
  607. return MAZE_ID;
  608.     YY_BREAK
  609. case 5:
  610. # line 73 "lev_comp.l"
  611. return LEVEL_ID;
  612.     YY_BREAK
  613. case 6:
  614. # line 74 "lev_comp.l"
  615. return GEOMETRY_ID;
  616.     YY_BREAK
  617. case 7:
  618. # line 75 "lev_comp.l"
  619. { BEGIN MAPC; line_number++; }
  620.     YY_BREAK
  621. case 8:
  622. # line 76 "lev_comp.l"
  623. return OBJECT_ID;
  624.     YY_BREAK
  625. case 9:
  626. # line 77 "lev_comp.l"
  627. return MONSTER_ID;
  628.     YY_BREAK
  629. case 10:
  630. # line 78 "lev_comp.l"
  631. return TRAP_ID;
  632.     YY_BREAK
  633. case 11:
  634. # line 79 "lev_comp.l"
  635. return DOOR_ID;
  636.     YY_BREAK
  637. case 12:
  638. # line 80 "lev_comp.l"
  639. return DRAWBRIDGE_ID;
  640.     YY_BREAK
  641. case 13:
  642. # line 81 "lev_comp.l"
  643. return MAZEWALK_ID;
  644.     YY_BREAK
  645. case 14:
  646. # line 82 "lev_comp.l"
  647. return REGION_ID;
  648.     YY_BREAK
  649. case 15:
  650. # line 83 "lev_comp.l"
  651. return RANDOM_OBJECTS_ID;
  652.     YY_BREAK
  653. case 16:
  654. # line 84 "lev_comp.l"
  655. return RANDOM_MONSTERS_ID;
  656.     YY_BREAK
  657. case 17:
  658. # line 85 "lev_comp.l"
  659. return RANDOM_PLACES_ID;
  660.     YY_BREAK
  661. case 18:
  662. # line 86 "lev_comp.l"
  663. return ALTAR_ID;
  664.     YY_BREAK
  665. case 19:
  666. # line 87 "lev_comp.l"
  667. return LADDER_ID;
  668.     YY_BREAK
  669. case 20:
  670. # line 88 "lev_comp.l"
  671. return NON_DIGGABLE_ID;
  672.     YY_BREAK
  673. case 21:
  674. # line 89 "lev_comp.l"
  675. return ROOM_ID;
  676.     YY_BREAK
  677. case 22:
  678. # line 90 "lev_comp.l"
  679. { yylval.i=D_ISOPEN; return DOOR_STATE; }
  680.     YY_BREAK
  681. case 23:
  682. # line 91 "lev_comp.l"
  683. { yylval.i=D_CLOSED; return DOOR_STATE; }
  684.     YY_BREAK
  685. case 24:
  686. # line 92 "lev_comp.l"
  687. { yylval.i=D_LOCKED; return DOOR_STATE; }
  688.     YY_BREAK
  689. case 25:
  690. # line 93 "lev_comp.l"
  691. { yylval.i=D_NODOOR; return DOOR_STATE; }
  692.     YY_BREAK
  693. case 26:
  694. # line 94 "lev_comp.l"
  695. { yylval.i=D_BROKEN; return DOOR_STATE; }
  696.     YY_BREAK
  697. case 27:
  698. # line 95 "lev_comp.l"
  699. { yylval.i=W_NORTH; return DIRECTION; }
  700.     YY_BREAK
  701. case 28:
  702. # line 96 "lev_comp.l"
  703. { yylval.i=W_EAST; return DIRECTION; }
  704.     YY_BREAK
  705. case 29:
  706. # line 97 "lev_comp.l"
  707. { yylval.i=W_SOUTH; return DIRECTION; }
  708.     YY_BREAK
  709. case 30:
  710. # line 98 "lev_comp.l"
  711. { yylval.i=W_WEST; return DIRECTION; }
  712.     YY_BREAK
  713. case 31:
  714. # line 99 "lev_comp.l"
  715. { yylval.i = -1; return RANDOM_TYPE; }
  716.     YY_BREAK
  717. case 32:
  718. # line 100 "lev_comp.l"
  719. return O_REGISTER;
  720.     YY_BREAK
  721. case 33:
  722. # line 101 "lev_comp.l"
  723. return M_REGISTER;
  724.     YY_BREAK
  725. case 34:
  726. # line 102 "lev_comp.l"
  727. return P_REGISTER;
  728.     YY_BREAK
  729. case 35:
  730. # line 103 "lev_comp.l"
  731. return A_REGISTER;
  732.     YY_BREAK
  733. case 36:
  734. # line 104 "lev_comp.l"
  735. { yylval.i=1; return LEFT_OR_RIGHT; }
  736.     YY_BREAK
  737. case 37:
  738. # line 105 "lev_comp.l"
  739. { yylval.i=3; return LEFT_OR_RIGHT; }
  740.     YY_BREAK
  741. case 38:
  742. # line 106 "lev_comp.l"
  743. { yylval.i=2; return CENTER; }
  744.     YY_BREAK
  745. case 39:
  746. # line 107 "lev_comp.l"
  747. { yylval.i=1; return TOP_OR_BOT; }
  748.     YY_BREAK
  749. case 40:
  750. # line 108 "lev_comp.l"
  751. { yylval.i=3; return TOP_OR_BOT; }
  752.     YY_BREAK
  753. case 41:
  754. # line 109 "lev_comp.l"
  755. { yylval.i=1; return LIGHT_STATE; }
  756.     YY_BREAK
  757. case 42:
  758. # line 110 "lev_comp.l"
  759. { yylval.i=0; return LIGHT_STATE; }
  760.     YY_BREAK
  761. case 43:
  762. # line 111 "lev_comp.l"
  763. { yylval.i=A_LAW; return ALIGNMENT; }
  764.     YY_BREAK
  765. case 44:
  766. # line 112 "lev_comp.l"
  767. { yylval.i=A_NEUTRAL; return ALIGNMENT; }
  768.     YY_BREAK
  769. case 45:
  770. # line 113 "lev_comp.l"
  771. { yylval.i=A_CHAOS; return ALIGNMENT; }
  772.     YY_BREAK
  773. case 46:
  774. # line 114 "lev_comp.l"
  775. { yylval.i=1; return ALTAR_TYPE; }
  776.     YY_BREAK
  777. case 47:
  778. # line 115 "lev_comp.l"
  779. { yylval.i=0; return ALTAR_TYPE; }
  780.     YY_BREAK
  781. case 48:
  782. # line 116 "lev_comp.l"
  783. { yylval.i=1; return UP_OR_DOWN; }
  784.     YY_BREAK
  785. case 49:
  786. # line 117 "lev_comp.l"
  787. { yylval.i=0; return UP_OR_DOWN; }
  788.     YY_BREAK
  789. case 50:
  790. # line 118 "lev_comp.l"
  791. { yylval.i=atoi(yytext); return INTEGER; }
  792.     YY_BREAK
  793. case 51:
  794. # line 119 "lev_comp.l"
  795. { yytext[yyleng-1] = 0; /* Discard the trailing \" */
  796.           yylval.map = (char *) alloc(strlen(yytext+1)+1);
  797.           strcpy(yylval.map, yytext+1); /* Discard the first \" */
  798.           return STRING; }
  799.     YY_BREAK
  800. case 52:
  801. # line 123 "lev_comp.l"
  802. { line_number++; }
  803.     YY_BREAK
  804. case 53:
  805. # line 124 "lev_comp.l"
  806. ;
  807.     YY_BREAK
  808. case 54:
  809. # line 125 "lev_comp.l"
  810. { yylval.i = yytext[1]; return CHAR; }
  811.     YY_BREAK
  812. case 55:
  813. # line 126 "lev_comp.l"
  814. { return yytext[0]; }
  815.     YY_BREAK
  816. case 56:
  817. # line 127 "lev_comp.l"
  818. ECHO;
  819.     YY_BREAK
  820. case YY_STATE_EOF(INITIAL):
  821. case YY_STATE_EOF(MAPC):
  822.     yyterminate();
  823.  
  824.         case YY_END_OF_BUFFER:
  825.             /* undo the effects of YY_DO_BEFORE_ACTION */
  826.             *yy_cp = yy_hold_char;
  827.  
  828.             yytext = yy_bp;
  829.  
  830.             switch ( yy_get_next_buffer() )
  831.             {
  832.             case EOB_ACT_END_OF_FILE:
  833.                 {
  834.                 if ( yywrap() )
  835.                 {
  836.                 /* note: because we've taken care in
  837.                  * yy_get_next_buffer() to have set up yytext,
  838.                  * we can now set up yy_c_buf_p so that if some
  839.                  * total hoser (like flex itself) wants
  840.                  * to call the scanner after we return the
  841.                  * YY_NULL, it'll still work - another YY_NULL
  842.                  * will get returned.
  843.                  */
  844.                 yy_c_buf_p = yytext;
  845.  
  846.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  847.                 goto do_action;
  848.                 }
  849.  
  850.                 else
  851.                 YY_NEW_FILE;
  852.                 }
  853.                 break;
  854.  
  855.             case EOB_ACT_RESTART_SCAN:
  856.                 yy_c_buf_p = yytext;
  857.                 yy_hold_char = *yy_c_buf_p;
  858.                 break;
  859.  
  860.             case EOB_ACT_LAST_MATCH:
  861.                 yy_c_buf_p = &yy_ch_buf[yy_n_chars];
  862.  
  863.                 yy_current_state = yy_get_previous_state();
  864.  
  865.                 yy_cp = yy_c_buf_p;
  866.                 yy_bp = yytext;
  867.                 continue; /* go to "YY_DO_BEFORE_ACTION" */
  868.             }
  869.             break;
  870.  
  871.         default:
  872.             printf( "action # %d\n", yy_act );
  873.             YY_FATAL_ERROR( "fatal flex scanner internal error" );
  874.         }
  875.  
  876.         break; /* exit bogus while loop */
  877.         }
  878.     }
  879.     }
  880.  
  881.  
  882. /* yy_get_next_buffer - try to read in new buffer
  883.  *
  884.  * synopsis
  885.  *     int yy_get_next_buffer();
  886.  *     
  887.  * returns a code representing an action
  888.  *     EOB_ACT_LAST_MATCH - 
  889.  *     EOB_ACT_RESTART_SCAN - restart the scanner
  890.  *     EOB_ACT_END_OF_FILE - end of file
  891.  */
  892.  
  893. static int yy_get_next_buffer()
  894.  
  895.     {
  896.     register char *dest = yy_ch_buf;
  897.     register char *source = yytext - 1; /* copy prev. char, too */
  898.     register int number_to_move, i;
  899.     int ret_val;
  900.     
  901.     if ( yy_c_buf_p != &yy_ch_buf[yy_n_chars + 1] )
  902.     {
  903.     YY_FATAL_ERROR( "NULL in input" );
  904.     /*NOTREACHED*/
  905.     }
  906.  
  907.     /* try to read more data */
  908.  
  909.     /* first move last chars to start of buffer */
  910.     number_to_move = yy_c_buf_p - yytext;
  911.  
  912.     for ( i = 0; i < number_to_move; ++i )
  913.     *(dest++) = *(source++);
  914.  
  915.     if ( yy_eof_has_been_seen )
  916.     /* don't do the read, it's not guaranteed to return an EOF,
  917.      * just force an EOF
  918.      */
  919.     yy_n_chars = 0;
  920.  
  921.     else
  922.     {
  923.     int num_to_read = YY_BUF_SIZE - number_to_move - 1;
  924.  
  925.     if ( num_to_read > YY_READ_BUF_SIZE )
  926.         num_to_read = YY_READ_BUF_SIZE;
  927.  
  928.     /* read in more data */
  929.     YY_INPUT( (&yy_ch_buf[number_to_move]), yy_n_chars, num_to_read );
  930.     }
  931.  
  932.     if ( yy_n_chars == 0 )
  933.     {
  934.     if ( number_to_move == 1 )
  935.         ret_val = EOB_ACT_END_OF_FILE;
  936.     else
  937.         ret_val = EOB_ACT_LAST_MATCH;
  938.  
  939.     yy_eof_has_been_seen = 1;
  940.     }
  941.  
  942.     else
  943.     ret_val = EOB_ACT_RESTART_SCAN;
  944.  
  945.     yy_n_chars += number_to_move;
  946.     yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  947.     yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  948.  
  949.     /* yytext begins at the second character in
  950.      * yy_ch_buf; the first character is the one which
  951.      * preceded it before reading in the latest buffer;
  952.      * it needs to be kept around in case it's a
  953.      * newline, so yy_get_previous_state() will have
  954.      * with '^' rules active
  955.      */
  956.  
  957.     yytext = &yy_ch_buf[1];
  958.  
  959.     return ( ret_val );
  960.     }
  961.  
  962.  
  963. /* yy_get_previous_state - get the state just before the EOB char was reached
  964.  *
  965.  * synopsis
  966.  *     yy_state_type yy_get_previous_state();
  967.  */
  968.  
  969. static yy_state_type yy_get_previous_state()
  970.  
  971.     {
  972.     register yy_state_type yy_current_state;
  973.     register char *yy_cp;
  974.  
  975.     register char *yy_bp = yytext;
  976.  
  977.     yy_current_state = yy_start;
  978.     if ( yy_bp[-1] == '\n' )
  979.     ++yy_current_state;
  980.  
  981.     for ( yy_cp = yytext; yy_cp < yy_c_buf_p; ++yy_cp )
  982.     {
  983.     register char yy_c = yy_ec[*yy_cp];
  984.     if ( yy_accept[yy_current_state] )
  985.         {
  986.         yy_last_accepting_state = yy_current_state;
  987.         yy_last_accepting_cpos = yy_cp;
  988.         }
  989.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  990.         {
  991.         yy_current_state = yy_def[yy_current_state];
  992.         if ( yy_current_state >= 274 )
  993.         yy_c = yy_meta[yy_c];
  994.         }
  995.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  996.     }
  997.  
  998.     return ( yy_current_state );
  999.     }
  1000.  
  1001.  
  1002. #ifdef __STDC__
  1003. static void yyunput( int c, register char *yy_bp )
  1004. #else
  1005. static void yyunput( c, yy_bp )
  1006. int c;
  1007. register char *yy_bp;
  1008. #endif
  1009.  
  1010.     {
  1011.     register char *yy_cp = yy_c_buf_p;
  1012.  
  1013.     *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
  1014.  
  1015.     if ( yy_cp < yy_ch_buf + 2 )
  1016.     { /* need to shift things up to make room */
  1017.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  1018.     register char *dest = &yy_ch_buf[YY_BUF_SIZE + 2];
  1019.     register char *source = &yy_ch_buf[number_to_move];
  1020.  
  1021.     while ( source > yy_ch_buf )
  1022.         *--dest = *--source;
  1023.  
  1024.     yy_cp += dest - source;
  1025.     yy_bp += dest - source;
  1026.  
  1027.     if ( yy_cp < yy_ch_buf + 2 )
  1028.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1029.     }
  1030.  
  1031.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1032.     yy_cp[-2] = '\n';
  1033.  
  1034.     *--yy_cp = c;
  1035.  
  1036.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  1037.     }
  1038.  
  1039.  
  1040. static int input()
  1041.  
  1042.     {
  1043.     int c;
  1044.     char *yy_cp = yy_c_buf_p;
  1045.  
  1046.     *yy_cp = yy_hold_char;
  1047.  
  1048.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1049.     { /* need more input */
  1050.     yytext = yy_c_buf_p;
  1051.     ++yy_c_buf_p;
  1052.  
  1053.     switch ( yy_get_next_buffer() )
  1054.         {
  1055.         /* this code, unfortunately, is somewhat redundant with
  1056.          * that above
  1057.          */
  1058.         case EOB_ACT_END_OF_FILE:
  1059.         {
  1060.         if ( yywrap() )
  1061.             {
  1062.             yy_c_buf_p = yytext;
  1063.             return ( EOF );
  1064.             }
  1065.  
  1066.         yy_ch_buf[0] = '\n';
  1067.         yy_n_chars = 1;
  1068.         yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1069.         yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1070.         yy_eof_has_been_seen = 0;
  1071.         yytext = yy_c_buf_p = &yy_ch_buf[1];
  1072.         yy_hold_char = *yy_c_buf_p;
  1073.  
  1074.         return ( input() );
  1075.         }
  1076.         break;
  1077.  
  1078.         case EOB_ACT_RESTART_SCAN:
  1079.         yy_c_buf_p = yytext;
  1080.         break;
  1081.  
  1082.         case EOB_ACT_LAST_MATCH:
  1083.         YY_FATAL_ERROR( "unexpected last match in input()" );
  1084.         }
  1085.     }
  1086.  
  1087.     c = *yy_c_buf_p;
  1088.     yy_hold_char = *++yy_c_buf_p;
  1089.  
  1090.     return ( c );
  1091.     }
  1092.  
  1093.  
  1094. #ifdef __STDC__
  1095. static void yyrestart( FILE *input_file )
  1096. #else
  1097. static void yyrestart( input_file )
  1098. FILE *input_file;
  1099. #endif
  1100.  
  1101.     {
  1102.     if ( yyin != stdin )
  1103.     fclose( yyin );
  1104.  
  1105.     yyin = input_file;
  1106.     yy_init = 1;
  1107.     }
  1108. # line 127 "lev_comp.l"
  1109.  
  1110. #ifdef    AMIGA
  1111. long *alloc(n)
  1112.     unsigned n;
  1113. {
  1114.     return ((long *)malloc (n));
  1115. }
  1116. #endif
  1117.